﻿Imports System.ComponentModel
Imports TodoMicroSolutionPackV1.dal.dto
Imports TodoMicroSolutionPackV1.productos.dal.dto
Namespace facturacion.dal.dto
    Public Class comprobanteItem

        Private _id As Integer
        Private _comprobante As comprobante
        Private _cantidad As Double
        Private _producto As producto
        Private _descripcion As String
        Private _stock As stock
        Private _precio_neto As Double

        <Browsable(False)>
        Public Overridable Property id As Integer
            Get
                Return _id
            End Get
            Set(ByVal value As Integer)
                _id = value
            End Set
        End Property
        <Browsable(False)>
        Public Overridable Property comprobante As comprobante
            Get
                Return _comprobante
            End Get
            Set(ByVal value As comprobante)
                _comprobante = value
            End Set
        End Property
        <DisplayName("Cantidad")>
        Public Overridable Property cantidad As Double
            Get
                Return _cantidad
            End Get
            Set(ByVal value As Double)
                _cantidad = value
            End Set
        End Property
        <Browsable(False)>
        Public Overridable Property producto As producto
            Get
                Return _producto
            End Get
            Set(ByVal value As producto)
                _producto = value
            End Set
        End Property
        <Browsable(False)>
        Public Overridable ReadOnly Property unidad_medida As constante
            Get
                Return _producto.unidad_medida
            End Get
        End Property
        <Browsable(False)>
        Public Overridable ReadOnly Property unidad_medida_codigo As Integer
            Get
                Return unidad_medida.codigo
            End Get
        End Property
        <DisplayName("Unidad de medida")>
        Public Overridable ReadOnly Property unidad_medida_valor As String
            Get
                Return unidad_medida.valor
            End Get
        End Property
        <DisplayName("Codigo")>
        Public Overridable ReadOnly Property codigo As String
            Get
                Return _producto.codigo
            End Get
        End Property
        <DisplayName("Descripcion")>
        Public Overridable Property descripcion As String
            Get
                Return _descripcion
            End Get
            Set(ByVal value As String)
                _descripcion = value
            End Set
        End Property
        <Browsable(False)>
        Public Overridable Property stock As stock
            Get
                Return _stock
            End Get
            Set(ByVal value As stock)
                _stock = value
            End Set
        End Property
        Private ReadOnly Property stockIsOK As Boolean
            Get
                Return True '_stock.producto = _producto
            End Get
        End Property
        <DisplayName("Numero de Despacho")>
        Public Overridable ReadOnly Property numero_despacho As String
            Get
                Return _stock.despacho_id
            End Get
        End Property
        <DisplayName("IVA")>
        Public Overridable ReadOnly Property iva_valor As Double
            Get
                Return producto.iva_valor
            End Get
        End Property
        <Browsable(False)>
        Public Overridable ReadOnly Property iva_codigo As Integer
            Get
                Return producto.iva.codigo
            End Get
        End Property
        <DisplayName("Precio Neto")>
        Public Overridable Property precio_neto As Double
            Get
                Return _precio_neto
            End Get
            Set(ByVal value As Double)
                _precio_neto = value
            End Set
        End Property
        <DisplayName("Precio Bruto")>
        Public Overridable ReadOnly Property precio_bruto As Double
            Get
                Return _precio_neto * (CDbl(producto.iva.valor) / 100 + 1)
            End Get
        End Property
        <Browsable(False)>
        Public Overridable ReadOnly Property precio_total_neto As Double
            Get
                Return _precio_neto * _cantidad
            End Get
        End Property
        <DisplayName("Subtotal")>
        Public Overridable ReadOnly Property precio_total_bruto As Double
            Get
                Return _precio_neto * _cantidad * (CDbl(producto.iva.valor) / 100 + 1)
            End Get
        End Property
        <Browsable(False)>
        Public Overridable ReadOnly Property importe_iva_total As Double
            Get
                Return precio_total_neto * CDbl(producto.iva.valor) / 100
            End Get
        End Property
        Public Sub New()

        End Sub
        Public Sub New(ByVal cantidad As Double, ByVal producto As producto, ByVal descripcion As String, ByVal stock As stock, ByVal precio_neto As Double)
            _cantidad = cantidad
            _producto = producto
            _descripcion = descripcion
            _stock = stock
            _precio_neto = precio_neto
        End Sub
    End Class

End Namespace
